var App = require("../../base/app");
var utils = require("../../utils/utils");
var common = require("./common");
var inTask = require("./inTask");
var shanDianSouSuo = new App("闪电搜索", {
  interval: 10,
});
var aRead = require("./aRead");
var aEat1 = require("./aEat1");
var aEat2 = require("./aEat2");
var aEat3 = require("./aEat3");
var aEat4 = require("./aEat4");
var aSleepGet = require("./aSleepGet");
var aSleep = require("./aSleep");
var aWalk = require("./aWalk");
var aSearch5 = require("./aSearch5");
var aSearch30 = require("./aSearch30");
var aTreasure = require("./aTreasure");
shanDianSouSuo.as = [
  aEat1,
  aEat2,
  aEat3,
  aEat4,
  aSleepGet,
  aSleep,
  aWalk,
];
shanDianSouSuo.run = function () {
  var content = "去悟空浏览器";
  if (utils.clickTextStartsWith(content)) {
    sleep(utils.getRandom(5, 7, 1000));
    this.runCount = this.runCount + 1;
    this.close();
    return;
  }
  aRead.flow();
  if (common.inHome()) {
    sleep(utils.getRandom(1.5, 2, 1000));
    common.toTask();
    sleep(utils.getRandom(5, 12, 1000));
    utils.swipeX(
      device.width / 2,
      (device.height / 10) * 5,
      device.width / 2,
      (device.height / 10) * 8,
      utils.getRandom(500, 800)
    );
    sleep(utils.getRandom(1.5, 2, 1000));
    inTask.run();
    var nextAction = this.getNextAction();
    if (nextAction) {
      nextAction.flow();
    } else {
      aSearch5.flow();
      aSearch30.flow();
      aTreasure.flow();
    }
  }
};

module.exports = shanDianSouSuo;
